import React from 'react'
import { Tabs, Card } from "antd-mobile"
import "./indexgoods.less"
import { withRouter } from 'react-router-dom'
let arr = ["one", "two", "three", "fore"]
function indexgoods(props) {
    let { shouye, pre, n, changeHomeN } = props
    console.log(shouye);
    return (
        <div className='indexgoods'>
            <Tabs onChange={(e) => { changeHomeN(Number(e)) }}>
                {arr.map((item, index) => {
                    return (
                        <Tabs.Tab title={item} key={index}>
                            {shouye.length>0 ? (
                                <>
                                    {shouye[n].content.map((i) => {
                                        return (
                                            <Card title={i.goodsname} key={i.id} onClick={(e) => { console.log(e); }}>
                                                <img src={pre + i.img} alt="" width={100} />
                                                <div>
                                                    <p>{i.description}</p>
                                                    <p>价格：{i.price}</p>
                                                    <p>原价：{i.market_price}</p>
                                                </div>
                                                <button onClick={() => { props.history.push("/detail/" + i.id+"/type=1") }}>加入购物车</button>
                                            </Card>
                                        )
                                    })}
                                </>
                            ) : <div>暂无数据</div>}
                        </Tabs.Tab>
                    )
                })}
            </Tabs>
        </div >
    )
}

export default withRouter(indexgoods)